<!DOCTYPE html>
<html>
<head>
<link href="./css/modern.css" rel="stylesheet">
<link href="./css/style-student.css" rel="stylesheet" type="text/css">
</head>
<script>
function DeleteValidation()
{
	var radios = document.getElementsByName('courseNumber');
	for(var i =0; i< radios.length; i++)
	{
		if(radios[i].checked){
			var confirmBox=confirm("Are you sure you want to Delete the course? All grades and student information will deleted!");
			if (confirmBox==true)
			{
			  	return true;
			}
			else
			{
			  	return false;
			}
		}
	}
	
	alert("Please Select a a course to Delete!");
	return false;
}

function DeleteAllValidation()
{
	var confirmBox=confirm("Are you sure you want to Clear the Database? All information except the Admin will be permanently erased!");
	if (confirmBox==true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ViewValidation()
{
	var radios = document.getElementsByName('courseNumber');
	for(var i =0; i< radios.length; i++)
	{
		if(radios[i].checked){
			return true;
		}
	}
	
	alert("Please Select a Course to View!");
	return false;
}
</script>

<body>
	<%@ page import="java.util.ArrayList"%>
	<%@ page import="com.eece496.Helpers.CourseInfo"%>
	<%
		String firstname = (String) request.getAttribute("firstname");
		String lastname = (String) request.getAttribute("lastname");
		ArrayList<CourseInfo> info= (ArrayList<CourseInfo>) request.getAttribute("CourseInfo");
		String isEmpty = (String) request.getAttribute("isEmpty");
	%>

	<div id="container">
		<div id="header">
			<br>
			<h1 id="main-title">
				<b><font color="000000"> EECE Student Group Assessments</b></font>
			</h1>
			<h2>
				Welcome
				<%=firstname%>
				<%=lastname%>! 
				 <a href="index.html">
					<p align="right">
						<font size="5">Logout</font>
					</p>
				</a>
			</h2>
		

		</div>
		<div id="body">
		 <div id="innerBody" class="page-region-content tiles">
			<br>
			<h1>Professor Portal</h1>
			<br>
			<form action="ProfCourseServlet" id="myform" method="get">
				<table cellspacing="0" cellpadding="0" border="0" width="325"
					class="striped" border=1>
					<tr>
						<td>
							<table cellspacing="0" cellpadding="1" border="0" width="300"
								class="striped" border=1>
								<tr>
									<th>Course List</th>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<div style="height: 300px; width: 1000px; overflow: auto;">
								<table class="fixed" cellspacing="0" cellpadding="1" border="0"
									width="300" class="striped" border=1>
									<tr>
										<td><b></b></td>
										<td><b>Course</b></td>
										<td><b>Course Name</b></td>
										<td><b>Section</b></td>
										<td><b>Term</b></td>
										<td><b>Year</b></td>
										<td><b>Instructor</b></td>
									</tr>
									<%
										for(CourseInfo myinfo: info ){
											if(isEmpty.equals("true"))
											{
												break;
											}
									%>
									<tr>
										<td><label class="radio" onclick=""> 
												<input type="radio" name="courseNumber" value="<%=myinfo.courseNumber%>/<%=myinfo.sectionNumber%>" />
										</label></td>
										<td><%=myinfo.courseNumber%></td>
										<td><%=myinfo.courseName%></td>
										<td><%=myinfo.sectionNumber%></td>
										<td><%=myinfo.term%></td>
										<td><%=myinfo.termYear%></td>
										<td><%=myinfo.instructor%></td>
									</tr>
									<%
										}
									%>
								</table>
							</div>
						</td>
					</tr>
				</table>
				<%
					if(isEmpty.equals("true")){
				%>
				<p>There are no courses added to the System.</p>
				<%
					}
				%>
				
				
				<input type = "hidden" name = "firstname" value = <%=firstname%>>
				<input type = "hidden" name = "lastname" value = <%=lastname%>>
				<input type="submit"  name = "button" value="Add New Course"/>
				<input type="submit" name = "button" value="Delete Course" onclick="return DeleteValidation()"/>
				<input type="submit" name = "button" value="View Course" onclick ="return ViewValidation()"/>
				<input type="submit" name = "button" value="Clear Database" onclick ="return DeleteAllValidation()"/>
			</form>
			</div>
		</div>
		<div id="footer">&copy;University of British Columbia. Styled with <a href="http://metroui.org.ua">Metro UI CSS</a> </div>
	</div>
</body>
</html>